import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/ScreenFull',
    component: () => import('@/views/DaPing/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: () => import('@/views/DaPing/index'),
    hidden: true
  },

  {
    path: '/FengXianFenXi',
    component: Layout,
    name: 'FengXianFenXi',
    meta: { title: '风险分析' },
    children: [
      {
        path: 'QiYeJianCeCang',
        name: 'QiYeJianCeCang',
        component: () => import('@/views/FengXianFenXi/QiYeJianCeCang/index'),
        meta: { title: '企业监测舱', icon: 'table' }
      },
      {
        path: 'KaoHeKanBan',
        name: 'KaoHeKanBan',
        component: () => import('@/views/FengXianFenXi/KaoHeKanBan/index'),
        meta: { title: '考核看板', icon: 'table' }
      },
      {
        path: 'DiTuDaoHang',
        name: 'DiTuDaoHang',
        component: () => import('@/views/FengXianFenXi/DiTuDaoHang/index'),
        meta: { title: '地图导航', icon: 'table' }
      },
      {
        path: 'WeiTiJiaoZiLiaoQiYe',
        name: 'WeiTiJiaoZiLiaoQiYe',
        component: () => import('@/views/FengXianFenXi/WeiTiJiaoZiLiaoQiYe/index'),
        meta: { title: '未提交资料企业', icon: 'table' }
      },
      {
        path: 'QiYeFengXianZhiPaiMingBiao',
        name: 'QiYeFengXianZhiPaiMingBiao',
        component: () => import('@/views/FengXianFenXi/QiYeFengXianZhiPaiMingBiao/index'),
        meta: { title: '企业风险值排名表', icon: 'table' }
      },
      {
        path: 'XianChangFengXianZhiHuiZongBiao',
        name: 'XianChangFengXianZhiHuiZongBiao',
        component: () => import('@/views/FengXianFenXi/XianChangFengXianZhiHuiZongBiao/index'),
        meta: { title: '现场风险值汇总表', icon: 'table' }
      },
      {
        path: 'AnQuanGuanLiFenZhiHuiZongBiao',
        name: 'AnQuanGuanLiFenZhiHuiZongBiao',
        component: () => import('@/views/FengXianFenXi/AnQuanGuanLiFenZhiHuiZongBiao/index'),
        meta: { title: '安全管理分值汇总表', icon: 'table' }
      }
    ]
  },

  {
    path: '/FengXianPingGu',
    component: Layout,
    name: 'FengXianPingGu',
    meta: { title: '风险评估' },
    children: [
      {
        path: 'XianChangFengXianPingGu',
        name: 'XianChangFengXianPingGu',
        component: () => import('@/views/FengXianPingGu/XianChangFengXianPingGu/index'),
        meta: { title: '现场风险评估', icon: 'table' }
      },
      {
        path: 'XianChangFengXianPingGu2',
        name: 'XianChangFengXianPingGu2',
        component: () => import('@/views/FengXianPingGu/XianChangFengXianPingGu2/index'),
        meta: { title: '现场风险评估2', icon: 'table' }
      },
      {
        path: 'AnQuanGuanLiPingGu',
        name: 'AnQuanGuanLiPingGu',
        component: () => import('@/views/FengXianPingGu/AnQuanGuanLiPingGu/index'),
        meta: { title: '安全管理评估', icon: 'table' }
      },
      {
        path: 'QiYePingGuJieGuoGuanLi',
        name: 'QiYePingGuJieGuoGuanLi',
        component: () => import('@/views/FengXianPingGu/QiYePingGuJieGuoGuanLi/index'),
        meta: { title: '企业评估结果管理', icon: 'table' }
      },
      {
        path: 'ZhuanJiaKu',
        name: 'ZhuanJiaKu',
        component: () => import('@/views/FengXianPingGu/ZhuanJiaKu/index'),
        meta: { title: '专家库', icon: 'table' }
      },
      {
        path: 'QiYeKu',
        name: 'QiYeKu',
        component: () => import('@/views/FengXianPingGu/QiYeKu/index'),
        meta: { title: '企业库', icon: 'table' }
      },
      {
        path: 'QiYeXinXiDaoRu',
        name: 'QiYeXinXiDaoRu',
        component: () => import('@/views/FengXianPingGu/QiYeXinXiDaoRu/index'),
        meta: { title: '企业信息导入', icon: 'table' }
      },
      {
        path: 'XianChangFengXianYuanJingYanKu',
        name: 'XianChangFengXianYuanJingYanKu',
        component: () => import('@/views/FengXianPingGu/XianChangFengXianYuanJingYanKu/index'),
        meta: { title: '现场风险源经验库', icon: 'table' }
      },
      {
        path: 'KaoHeRenYuanWeiHu',
        name: 'KaoHeRenYuanWeiHu',
        component: () => import('@/views/FengXianPingGu/KaoHeRenYuanWeiHu/index'),
        meta: { title: '考核人员维护', icon: 'table' }
      },
      {
        path: 'QiYeKaoHeRenYuanWeiHu',
        name: 'QiYeKaoHeRenYuanWeiHu',
        component: () => import('@/views/FengXianPingGu/QiYeKaoHeRenYuanWeiHu/index'),
        meta: { title: '企业考核人员维护', icon: 'table' }
      },
      {
        path: 'JiChuShuXing',
        component: () => import('@/views/FengXianPingGu/JiChuShuXing/index'),
        name: 'JiChuShuXing',
        meta: { title: '基础属性', icon: 'table' },
        children: [
          {
            path: 'HangYeFenLei',
            component: () => import('@/views/FengXianPingGu/JiChuShuXing/HangYeFenLei/index'),
            name: 'HangYeFenLei',
            meta: { title: '行业分类' }
          },
          {
            path: 'QiYeLeiXing',
            component: () => import('@/views/FengXianPingGu/JiChuShuXing/QiYeLeiXing/index'),
            name: 'QiYeLeiXing',
            meta: { title: '企业类型' }
          }
        ]
      },
      {
        path: 'ZhengJianDaoQi',
        name: 'ZhengJianDaoQi',
        component: () => import('@/views/FengXianPingGu/ZhengJianDaoQi/index'),
        meta: { title: '证件到期', icon: 'table' }
      }
    ]
  },

  {
    path: '/FengXianMoXing',
    component: Layout,
    name: 'FengXianMoXing',
    meta: { title: '风险模型' },
    children: [
      {
        path: 'XianChangFengXianPingJiaZhiBiao',
        name: 'XianChangFengXianPingJiaZhiBiao',
        component: () => import('@/views/FengXianMoXing/XianChangFengXianPingJiaZhiBiao/index'),
        meta: { title: '现场风险评价指标', icon: 'table' }
      },
      {
        path: 'GuanLiXiangMuPingDingZhiBiao',
        name: 'GuanLiXiangMuPingDingZhiBiao',
        component: () => import('@/views/FengXianMoXing/GuanLiXiangMuPingDingZhiBiao/index'),
        meta: { title: '管理项目评定指标', icon: 'table' }
      },
      {
        path: 'XianChangFengXianPingJiaBiaoZhun',
        component: () => import('@/views/FengXianMoXing/XianChangFengXianPingJiaBiaoZhun/index'),
        name: 'XianChangFengXianPingJiaBiaoZhun',
        meta: { title: '现场风险评价标准', icon: 'table' },
        children: [
          {
            path: 'WeiXianShiJianKeNengXing',
            name: 'WeiXianShiJianKeNengXing',
            component: () => import('@/views/FengXianMoXing/XianChangFengXianPingJiaBiaoZhun/WeiXianShiJianKeNengXing/index'),
            meta: { title: '危险事件可能性', icon: 'table' }
          },
          {
            path: 'WeiXianHuanJingLeiXing',
            name: 'WeiXianHuanJingLeiXing',
            component: () => import('@/views/FengXianMoXing/XianChangFengXianPingJiaBiaoZhun/WeiXianHuanJingLeiXing/index'),
            meta: { title: '危险环境类型', icon: 'table' }
          },
          {
            path: 'WeiXianShiJianKeNengJieGuo',
            name: 'WeiXianShiJianKeNengJieGuo',
            component: () => import('@/views/FengXianMoXing/XianChangFengXianPingJiaBiaoZhun/WeiXianShiJianKeNengJieGuo/index'),
            meta: { title: '危险事件可能结果', icon: 'table' }
          }
        ]
      }
    ]
  },

  {
    path: '/XiTongGuanLi',
    component: Layout,
    name: 'XiTongGuanLi',
    meta: { title: '系统管理' },
    children: [
      {
        path: 'ZuZhiJiGou',
        name: 'ZuZhiJiGou',
        component: () => import('@/views/XiTongGuanLi/ZuZhiJiGou/index'),
        meta: { title: '组织机构', icon: 'table' }
      },
      {
        path: 'YongHuGuanli',
        name: 'YongHuGuanli',
        component: () => import('@/views/XiTongGuanLi/YongHuGuanli/index'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'JueSeGuanLi',
        name: 'JueSeGuanLi',
        component: () => import('@/views/XiTongGuanLi/JueSeGuanLi/index'),
        meta: { title: '角色管理', icon: 'table' }
      },
      {
        path: 'JueSeShouQuan',
        name: 'JueSeShouQuan',
        component: () => import('@/views/XiTongGuanLi/JueSeShouQuan/index'),
        meta: { title: '角色授权', icon: 'table' }
      },
      {
        path: 'CaiDanWeiHu',
        name: 'CaiDanWeiHu',
        component: () => import('@/views/XiTongGuanLi/CaiDanWeiHu/index'),
        meta: { title: '菜单维护', icon: 'table' }
      }
    ]
  },

  {
    path: '/DaPingXianShi',
    component: Layout,
    name: 'DaPingXianShi',
    meta: { title: '大屏显示' },
    children: [
      {
        path: 'QiYeJianCeCang',
        name: 'QiYeJianCeCang',
        component: () => import('@/views/DaPingXianShi/QiYeJianCeCang/index'),
        meta: { title: '企业监测舱', icon: 'table' }
      },
      {
        path: 'DaPingXianShiRe',
        name: 'DaPingXianShiRe',
        component: () => import('@/views/DaPingXianShi/DaPingXianShi/index'),
        meta: { title: '大屏显示', icon: 'table' }
      }
    ]
  },
  {
    path: '/PingGuXianShi',
    component: Layout,
    name: 'PingGuXianShi',
    meta: { title: '评估显示' },
    children: [
      {
        path: 'XianChangGuanLiPingGu',
        name: 'XianChangGuanLiPingGu',
        component: () => import('@/views/PingGuXianShi/XianChangGuanLiPingGu/index'),
        meta: { title: '现场管理评估', icon: 'table' }
      },
      {
        path: 'AnQuanGuanLiPingGu',
        name: 'AnQuanGuanLiPingGu',
        component: () => import('@/views/PingGuXianShi/AnQuanGuanLiPingGu/index'),
        meta: { title: '安全管理评估', icon: 'table' }
      },
      {
        path: 'QiYePingGuJieGuoGuanLi',
        name: 'QiYePingGuJieGuoGuanLi',
        component: () => import('@/views/PingGuXianShi/QiYePingGuJieGuoGuanLi/index'),
        meta: { title: '企业评估结果管理', icon: 'table' }
      },
      {
        path: 'QiYeKu',
        name: 'QiYeKu',
        component: () => import('@/views/PingGuXianShi/QiYeKu/index'),
        meta: { title: '企业库', icon: 'table' }
      },
      {
        path: 'ZhengJianDaoQi',
        name: 'ZhengJianDaoQi',
        component: () => import('@/views/PingGuXianShi/ZhengJianDaoQi/index'),
        meta: { title: '证件到期', icon: 'table' }
      }
    ]
  },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
